<%-- 
    Document   : ManagerComment
    Created on : Jul 11, 2011, 8:12:31 PM
    Author     : Hai
--%>


<%@page import="server.entity.Comment"%>
<%@page import="server.process.ProcessBeanLocal"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:include page="adminheader.jsp"></jsp:include>
            <div id="main">
                <div id="adminManager">
                    <jsp:include page="lefmenu.jsp"></jsp:include>
                </div>
                <div id="contentAdmin">
                    <fieldset>
                        <legend>Manage Comment</legend>

                        <h4>

                            <table border="1">
                                <thead>
                                    <tr>
                                        <th>CommentID</th>
                                        <th>CommentDate</th>
                                        <th>Email</th>
                                        <th>Username</th>
                                        <th>CommentContent</th>
                                        <th>PhotoID</th>
                                        <th>Approved</th>

                                    </tr>
                                </thead>
                                <tbody>

                                    <%  Context ctx = new InitialContext();
                                                DateFormat date = new SimpleDateFormat("MM/dd/yyyy");

                                                Object obj = ctx.lookup("ProcessLocalJNDI");
                                                ProcessBeanLocal lova = (ProcessBeanLocal) obj;
                                                Comment[] resulr = lova.businessMethod(true);
                                                for (int i = 0; i < resulr.length; i++) {

                                                    boolean isprsd = resulr[i].getApproved();
                                                    boolean satus=resulr[i].getStatus();




                                    %>

                                    <tr>
                                <form action="comment">
                                    <td><a href="viewdeatilcomment.jsp?name=<%=resulr[i].getCommentID()%>"><%=resulr[i].getCommentID()%></a></td>
                                    <td><%=date.format(resulr[i].getCommentDate())%></td>
                                    <td><%=resulr[i].getEmail()%></td>
                                    <td><%=resulr[i].getRegisteredUser().getUsername().toString()%></td>
                                    <td><%=(resulr[i].getCommentContent().length()>20)?resulr[i].getCommentContent().substring(0, 20):resulr[i].getCommentContent()%>...</td>
                                    <td><a href="#"><%=resulr[i].getPhoto().getPhotoID().toString()%></a></td>
                                    <td><input type="checkbox" checked="checked" name="321"  value="ON"<%if (isprsd) {%><%}%></td>

                                    <td><input type="hidden" name="txtcommentid" value="<%=resulr[i].getCommentID()%>" /></td>


                                    <td><input type="submit" value="Distable" name="action" /></td>
           
                                    <td><input type="submit" value="Reply" name="action" /></td>
                                    <input type="hidden" name="txtTrue" value="false" />
                                    <input type="hidden" name="id" value="<%=resulr[i].getCommentID()%>" />
                                    <input type="hidden" name="txth1" value="<%=date.format(resulr[i].getCommentDate())%>" />
                                    <input type="hidden" name="txth2" value="<%=resulr[i].getEmail()%>" />
                                    <input type="hidden" name="txth3" value="<%=resulr[i].getRegisteredUser().getUsername().toString()%>" />
                                    <input type="hidden" name="txth4" value="<%=resulr[i].getCommentContent()%>" />
                                    <input type="hidden" name="txth5" value="<%=resulr[i].getPhoto().getPhotoID()%>" />
                                </form>
                                </tr>


                                <% }
                                %>
                                </tbody>
                            </table>




                        </h4>

                    </fieldset>
                </div>
            </div>
            <div id="footer">

            </div>
        </div>
    </body>
</html>
